package com.example.designpattenexample.flyweight;

import java.util.HashMap;
import java.util.Map;

public class FlyweightFactory {

    private static Map<String, Flyweight> pool = new HashMap<>();

    public static Flyweight getFlyweight(String innerState) {
        Flyweight flyweight = pool.get(innerState);
        if (flyweight == null) {
            flyweight = new ConcreteFlyweight(innerState);
            pool.put(innerState, flyweight);
        }
        return flyweight;
    }


}
